<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>10.呼吸灯案例</title>
</head>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }
        .slider {
            height: 340px;
            width: 790px;
            margin: 100px auto;
            position: relative;
        }
        .slider {
            position: relative;
            margin: 100px auto;
        }
        .slider li {
            position: absolute;
            display: none;
        }
        .slider li:first-child {
            display: block;
        }
        .arrow {
            display: none;
        }
        .slider:hover .arrow {
            display: block;
        }
        .arrow-left,
        .arrow-right {
            font-family: "SimSun", "宋体";
            width: 30px;
            height: 60px;
            background-color: rgba(0, 0, 0, 0.1);
            position: absolute;
            top: 50%;
            margin-top: -30px;
            cursor: pointer;
            text-align: center;
            line-height: 60px;
            color: #fff;
            font-weight: 700;
            font-size: 30px;
        }
        .arrow-left:hover,
        .arrow-right:hover {
            background-color: rgba(0, 0, 0, 0.5);
        }
        .arrow-left {
            left: 0;
        }
        .arrow-right {
            right: 0;
        }
    </style>
<body>

    <div class="slider">
        <ul>
            <li><a href="#"><img src="img/huxideng01.jpg" alt=""></a></li>
            <li><a href="#"><img src="img/huxideng02.jpg" alt=""></a></li>
            <li><a href="#"><img src="img/huxideng03.jpg" alt=""></a></li>
            <li><a href="#"><img src="img/huxideng04.jpg" alt=""></a></li>
            <li><a href="#"><img src="img/huxideng05.jpg" alt=""></a></li>
            <li><a href="#"><img src="img/huxideng06.jpg" alt=""></a></li>
            <li><a href="#"><img src="img/huxideng07.jpg" alt=""></a></li>
        </ul>
        <!-- 箭头 -->
        <div class="arrow">
            <span class="arrow-left">&lt</span>
            <span class="arrow-right">&gt</span>
        </div>
    </div>

    <script src="../jquery-3.2.1.js"></script>
    <script>
        
        $(function(){
            var count = 0;
            $(".arrow-right").click(function(){
                count++;
                // 让count渐渐的显示 其他兄弟渐渐隐藏
                if(count == $(".slider li").length ){
                    count = 0;
                }
                $(".slider li").eq(count).fadeIn().siblings("li").fadeOut();
            });
            $(".arrow-left").click(function(){
                count--;
                if(count == -1){        // 不要使用jq的负数 虽然不会报错 它会自己找上一张 但还是用自己的
                    count = $(".slider li").length - 1;
                }
                $(".slider li").eq(count).fadeIn().siblings("li").fadeOut();
            });
        });

    </script>
</body>
</html>